
from rest_framework.documentation import include_docs_urls
from django.urls import path, re_path, include
from apps.goods.views import GoodsListViewSet, CategoryViewset, BannerViewset, IndexCategoryViewset, HotSearchsViewset
from apps.trade.views import ShoppingCartViewset
from apps.user_operation.views import UserFavViewset, LeavingMessageViewset, AddressViewset
from apps.users.views import SmsCodeViewset, UserViewset
from rest_framework.routers import DefaultRouter
from rest_framework.authtoken import views
from rest_framework_jwt.views import obtain_jwt_token

from apps.users.views import favicon_view

router = DefaultRouter()

router.register(r'goods', GoodsListViewSet, basename="goods")

# 配置Category的url
router.register(r'categories', CategoryViewset, basename="categories")

# 配置codes的url
router.register(r'code', SmsCodeViewset, basename="code")

# 配置users的url
router.register(r'users', UserViewset, basename="users")
# router.register(r'users/1/', UserInfoView, basename="users/1/")

# 配置用户收藏的url
router.register(r'userfavs', UserFavViewset, basename="userfavs")

# 配置用户留言的url
router.register(r'messages', LeavingMessageViewset, basename="messages")

# 收货地址
router.register(r'address', AddressViewset, basename="address")

# 购物车
router.register(r'shopcarts', ShoppingCartViewset, basename="shopcarts")

# 订单相关url
# router.register(r'orders', OrderViewset, basename="orders")

# 首页banner轮播图url
router.register(r'banners', BannerViewset, basename="banners")

# 首页系列商品展示url
router.register(r'indexgoods', IndexCategoryViewset, basename="indexgoods")

# 热搜词
router.register(r'hotsearchs', HotSearchsViewset, basename="hotsearchs")


urlpatterns = [
    # router的path路径
    re_path('^', include(router.urls)),
    # 自动化文档,1.11版本中注意此处前往不要加$符号
    path('docs/', include_docs_urls(title='mtianyan超市文档')),
    # 调试登录
    path('api-auth/', include('rest_framework.urls')),

    # drf自带的token授权登录,获取token需要向该地址post数据
    path('api-token-auth/', views.obtain_auth_token),

    # jwt的token认证
    path('login/', obtain_jwt_token),

    # # 首页
    # path('index/', IndexView.as_view(), name="index"),
    path('favicon.ico', favicon_view),
    # path('users/1/', UserInfoView.as_view())
]
